<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="mybean.data.*" %>
<%@ page import="java.util.*" %>
<%@ page import="javax.sql.rowset.*" %>
<jsp:useBean id="loginBean" class="mybean.data.login" scope="session"/>
<jsp:useBean id="dataBean" class="mybean.data.DataByPage" scope="session"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>维修厂信息</title>
	<link rel="stylesheet" type="text/css" href="css/reset.css">
	<link rel="stylesheet" type="text/css" href="css/common.css">
	<link rel="stylesheet" type="text/css" href="css/index-2.css">
	<link rel="stylesheet" type="text/css" href="css/index-1.css">
</head>
<body>
	<%@ include file="Ahead.txt" %>
	<div class="Admin-content">
	<center>
		<!-- 分页显示查询结果 -->		
		<jsp:setProperty name="dataBean" property="pageSize" param="pageSize"/><!-- 设置页大小和目前的页 -->
		<jsp:setProperty name="dataBean" property="currentPage" param="currentPage"/>
		<% 
			request.setCharacterEncoding("utf-8");
			response.setContentType("utf-8");
			CachedRowSet rowset=dataBean.getRowSet();
			if(rowset== null){
				out.print("<h2>没有查询到相关信息</h2>");
				return;
			}
			else{
				String button1="",button2="";
				rowset.last();
				int totalRecord=rowset.getRow();
				if(totalRecord==0){
					out.print("<h2>没有查询到相关信息</h2>");
					return ;
				}
			%>
		<h3>当前显示的是维修厂信息</h3>
		<table>
			<tr style="background-color: #004b97;color: white">
				<th width=100 height=40>维修厂编号</th>
				<th width=100 height=40>名称</th>
				<th width=100 height=40>联系电话</th>
				<th width=150 height=40>地址</th>
				<th width=100 height=40>操作</th>
			</tr>			
				<% 
				out.print("全部记录数"+totalRecord);//全部记录数
				int pageSize = dataBean.getPageSize();//每页显示的记录数
				int totalPages=dataBean.getTotalPages();
				if(totalRecord % pageSize==0)  totalPages=totalRecord/pageSize;//总页数
				else	totalPages=totalRecord/pageSize+1;
				dataBean.setPageSize(pageSize);
				dataBean.setTotalPages(totalPages);
				if(totalPages>=1){
					if(dataBean.getCurrentPage()<1)	dataBean.setCurrentPage(dataBean.getTotalPages());
					if(dataBean.getCurrentPage()>dataBean.getTotalPages())
						dataBean.setCurrentPage(1);
					int index = (dataBean.getCurrentPage()-1)*pageSize+1;
					rowset.absolute(index);//查询位置移动到currentPage页起始位置
					boolean boo=true;
					for(int i=1;i<=pageSize&&boo;i++){
						String number = rowset.getString("Fno");
						String name = rowset.getString("Fname");
						String tel = rowset.getString("Ftel");
						String addr= rowset.getString("Faddr");
						button1 = "<form action='changeFixshop.jsp' method='post'>"+//把单车信息传过去，省得再从数据库中查
									"<input type='hidden'  name='number' value="+number+" >"+
									"<input type='hidden'  name='name' value="+name+" >"+
									"<input type='hidden'  name='tel' value="+tel+" >"+
									"<input type='hidden'  name='addr' value="+addr+" >"+
								"&nbsp;&nbsp;<input type='submit'  value='修改' class='submit'></form>";
						button2 = "<form name='fixshop' action='deleteManagerServlet' method='post'>"+
								"<input type='hidden'  name='type' value='fixshop'>"+
								"<input type='hidden'  name='number' value="+number+" >"+
									"&nbsp;&nbsp;<input type='submit'  value='删除' class='submit'></form>";	
							
			%>
			<tr style="background-color: #c0c0c0;">
				<td height=50><center><%=number %></center></td>
				<td height=50><center><%=name %><center></td>
				<td height=50><center><%=tel %><center></td>
				<td height=50><center><%=addr %></center></td>
				<td height=50><center><%=button1 %><%=button2 %></center></td> 
			</tr>
				<%		boo=rowset.next();
					}
				}
				}
			%>	
		</table>
		<%@ include file="bypage.txt" %>
	</center>	
	</div>			
	<!--页面底部-->
	<!--所以的页面底部都一样，用一个文本文件存储，所有JSP文件使用嵌入-->
	<%@ include file="footer.txt" %>
</body>
</html>
</body>
</html>